﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data;
using Husb.Data;
using Husb.Util;
using GroundWater.Data;
using GroundWater.DataAccess;
using WellTable = GroundWater.Data.InfoDataSet.WellsDataTable;
using WellRow = GroundWater.Data.InfoDataSet.WellsRow;

namespace GroundWater.BusinessActions
{
    public class Well : DataAccessManager<InfoDataSet, WellTable, WellRow, WellDataAdapter>
    {
        public static WellTable GetAllWithCode()
        {
            WellDataAdapter adapter = new WellDataAdapter();
            WellTable tmp = adapter.GetAll(false, true, null);

            WellTable wells = new InfoDataSet.WellsDataTable();

            foreach (WellRow row in tmp.Rows)
            {
                wells.ImportRow(row);
            }

            foreach (WellRow well in wells.Rows)
            {
                if (well.Code.Length - 4 > 4)
                {
                    well.Name = well.Code.Substring(well.Code.Length - 4, 4) + well.Name;
                }
            }


            return wells;
        }




    }
}
